package com.rickpan.dto.response;

import com.rickpan.entity.Team;
import io.swagger.v3.oas.annotations.media.Schema;

import java.time.LocalDateTime;

/**
 * 团队响应DTO
 */
@Schema(description = "团队信息响应")
public class TeamResponse {

    @Schema(description = "团队ID", example = "1")
    private Long id;

    @Schema(description = "团队名称", example = "开发团队Alpha")
    private String name;

    @Schema(description = "团队描述", example = "专注于RickPan核心功能开发")
    private String description;

    @Schema(description = "团队状态", example = "APPROVED", allowableValues = {"PENDING", "APPROVED", "REJECTED", "ARCHIVED"})
    private Team.Status status;

    @Schema(description = "创建者ID", example = "1")
    private Long creatorId;

    @Schema(description = "创建者用户名", example = "admin")
    private String creatorName;

    @Schema(description = "当前成员数", example = "5")
    private Integer currentMembers;

    @Schema(description = "最大成员数", example = "50")
    private Integer maxMembers;

    @Schema(description = "团队头像URL", example = "https://example.com/avatar.jpg")
    private String teamAvatarUrl;

    @Schema(description = "创建时间", example = "2025-01-11T10:00:00")
    private LocalDateTime createdAt;

    @Schema(description = "更新时间", example = "2025-01-11T10:00:00")
    private LocalDateTime updatedAt;

    // 构造函数
    public TeamResponse() {}

    public TeamResponse(Team team) {
        this.id = team.getId();
        this.name = team.getName();
        this.description = team.getDescription();
        this.status = team.getStatus();
        this.creatorId = team.getCreatorId();
        this.currentMembers = team.getCurrentMembers();
        this.maxMembers = team.getMaxMembers();
        this.teamAvatarUrl = team.getTeamAvatarUrl();
        this.createdAt = team.getCreatedAt();
        this.updatedAt = team.getUpdatedAt();
    }

    // 静态工厂方法
    public static TeamResponse from(Team team) {
        return new TeamResponse(team);
    }

    // Getter和Setter方法
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Team.Status getStatus() {
        return status;
    }

    public void setStatus(Team.Status status) {
        this.status = status;
    }

    public Long getCreatorId() {
        return creatorId;
    }

    public void setCreatorId(Long creatorId) {
        this.creatorId = creatorId;
    }

    public String getCreatorName() {
        return creatorName;
    }

    public void setCreatorName(String creatorName) {
        this.creatorName = creatorName;
    }

    public Integer getCurrentMembers() {
        return currentMembers;
    }

    public void setCurrentMembers(Integer currentMembers) {
        this.currentMembers = currentMembers;
    }

    public Integer getMaxMembers() {
        return maxMembers;
    }

    public void setMaxMembers(Integer maxMembers) {
        this.maxMembers = maxMembers;
    }

    public String getTeamAvatarUrl() {
        return teamAvatarUrl;
    }

    public void setTeamAvatarUrl(String teamAvatarUrl) {
        this.teamAvatarUrl = teamAvatarUrl;
    }

    public LocalDateTime getCreatedAt() {
        return createdAt;
    }

    public void setCreatedAt(LocalDateTime createdAt) {
        this.createdAt = createdAt;
    }

    public LocalDateTime getUpdatedAt() {
        return updatedAt;
    }

    public void setUpdatedAt(LocalDateTime updatedAt) {
        this.updatedAt = updatedAt;
    }

    @Override
    public String toString() {
        return "TeamResponse{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", description='" + description + '\'' +
                ", status=" + status +
                ", creatorId=" + creatorId +
                ", creatorName='" + creatorName + '\'' +
                ", currentMembers=" + currentMembers +
                ", maxMembers=" + maxMembers +
                ", teamAvatarUrl='" + teamAvatarUrl + '\'' +
                ", createdAt=" + createdAt +
                ", updatedAt=" + updatedAt +
                '}';
    }
}
